class Solution:
    def strStr(self, haystack: str, needle: str) -> int:
        valid = len(needle)
        if valid > len(haystack):
            return -1
        for i in range(len(haystack)):
            flag = 0
            for j in range(len(needle)):
                if i < len(haystack) and haystack[i] == needle[j]:
                    flag += 1
                    i +=1
                else:
                    break
            if flag == valid:
                return i - valid         
        return -1